// @algorithm @lc id=1000234 lang=cpp
// @title VvJkup

#include "algm/algm.h"
#include <iostream>
#include <string>
#include <vector>
using namespace std;
class Solution {
public:
    vector<vector<int>> ans;
    vector<vector<int>> permute(vector<int> &nums) {
        int n = nums.size();
        dfs(nums, n, 0);
        return ans;
    }
    void dfs(vector<int> &nums, int n, int level) {
        if (level == n) {
            ans.push_back(nums);
            return;
        }
        for (int k = level; k < n; ++k) {
            swap(nums[level], nums[k]);
            dfs(nums, n, level + 1);
            swap(nums[level], nums[k]);
            // dfs(nums, n, level + 1);
        }
        return;
    }
};